package com.wpp;

/*
 *静态代理
 *
 * */
//1.定义一个接口,唱歌的功能
interface sing {
    void music();
}

//定义一个代理类,实现接口
class ProxySing implements sing {
    //定义一个sing对象
    private sing sing;

    //定义一个构造器
    public ProxySing(sing sing) {
        this.sing = sing;
    }

    //开始做事
    @Override
    public void music() {
        System.out.println("找赞助商");
        //歌手唱歌
        sing.music();
        System.out.println("处理后续工作");
    }
}

//定义一个被代理类
class ProxyMusicPerso implements sing {


    @Override
    public void music() {
        System.out.println("负责唱歌");
    }

}

public class StaticProxyTest {
    public static void main(String args[]) {

        //被代理类对象
        sing proxyMusicPerso = new ProxyMusicPerso();//多态

        //代理类对象
        ProxySing proxySing = new ProxySing(proxyMusicPerso);

        proxySing.music();//代理类调用唱歌的方法


    }
}
